/*
 * @Description: 
 * @Author: charles
 * @Date: 2021-11-15 16:41:27
 * @LastEditors: charles
 * @LastEditTime: 2021-11-15 16:55:51
 */
import {useEffect} from 'react'
import {connect} from 'dva'

function Article(props){
  console.log(props);
  // dva中react-router应用
  const toHomeHandler = (event)=>{
    event.preventDefault();
    props.history.push("/")
  }

  useEffect(() => {
    props.dispatch({type:"article/fetch",payload:{page:1,pageSize:10}})
  }, ['props.article']);

  return (
    <div>
      <h2>文章管理</h2>
      <a href="" onClick={toHomeHandler}>返回主页</a>
      <ul>
        {
          props.article.data.list.map(item=>{
            return (
              <li key={item.id}>{item.title}</li>
            )
          })
        }
      </ul>
    </div>
  )
}
export default connect(state=>state)(Article);
